package com.hjx.movie.persistence.system.model;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.hjx.movie.persistence.system.groups.Update;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * (IvyUser)实体类
 *
 * @author makejava
 * @since 2020-12-22 14:41:02
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class IvyUser implements Serializable {
    private static final long serialVersionUID = 848736993634652165L;

    @TableId
    @NotNull(groups = {Update.class})
    private Long userId;

    @NotBlank(message = "用户名不能为空")
    @Pattern(regexp = "^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,19}$",message="用户名格式不正确")
    private String username;

    private String password;

    @NotBlank(message = "昵称不能为空")
    private String nickname;

    @Email(message = "请输入符合格式的邮箱")
    private String email;

    @Pattern(regexp = "^1[0-9]{10}$",message = "手机号格式不正确")
    private String phone;
    /**
    * 用户头像
    */
    private String headPic;
    /**
    * 性别 女0 男1
    */
    private String gender;
    /**
    * 用户状态 0 锁定 1 正常
    */
    private Boolean status = true;
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @TableField(exist = false)
    private List<IvyRole> roles = new ArrayList<>(10);
}
